Skip to content

Commit c61fb85

Browse files
committedMay 31, 2019
Remove unused support for single source/dest settings in QgsCoordinateTransformContext
This has been #ifdef'ed out since it's original implementation, and it has no meaning in the world of Proj >= 6.0
1 parent 0c590a1 commit c61fb85

File tree

5 files changed

+9
-398
lines changed

5 files changed

+9
-398
lines changed
 

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,10 @@ class QgsCoordinateTransformContext
1717
%Docstring
1818
Contains information about the context in which a coordinate transform is executed.
1919

20-
The context stores various information regarding which coordinate transforms should
20+
The context stores various information regarding which coordinate operations should
2121
be used when transforming points from a source to destination coordinate reference
2222
system.
2323

24-
The highest priority transforms are those set using addSourceDestinationDatumTransform()
25-
and which the transform has a matching source to destination CRS pair.
26-
27-
Failing this, if the source CRS has a matching transform specified by
28-
addSourceDatumTransform() then this datum transform will be used. The same logic
29-
applies for destination CRS transforms set using addDestinationDatumTransform().
30-
3124
.. note::
3225

3326
QgsCoordinateTransformContext objects are thread safe for read and write.
@@ -70,8 +63,6 @@ Copy constructor
7063
Clears all stored transform information from the context.
7164
%End
7265

73-
74-
7566
QMap< QPair< QString, QString>, QgsDatumTransform::TransformPair > sourceDestinationDatumTransforms() const;
7667
%Docstring
7768
Returns the stored mapping for source to destination CRS pairs to associated datum transforms to use.

‎src/app/qgsdatumtransformtablewidget.cpp

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,7 @@ void QgsDatumTransformTableModel::removeTransform( const QModelIndexList &indexe
5757
int QgsDatumTransformTableModel::rowCount( const QModelIndex &parent ) const
5858
{
5959
Q_UNUSED( parent )
60-
return mTransformContext.sourceDestinationDatumTransforms().count()
61-
#ifdef singlesourcedest
62-
+ mTransformContext.sourceDatumTransforms().count()
63-
+ mTransformContext.destinationDatumTransforms().count()
64-
#endif
65-
;
60+
return mTransformContext.sourceDestinationDatumTransforms().count();
6661
}
6762

6863
int QgsDatumTransformTableModel::columnCount( const QModelIndex &parent ) const
@@ -78,19 +73,12 @@ QVariant QgsDatumTransformTableModel::data( const QModelIndex &index, int role )
7873
int sourceTransform = -1;
7974
int destinationTransform = -1;
8075

81-
#ifdef singlesourcedest
82-
if ( index.row() < mTransformContext.sourceDestinationDatumTransforms().count() )
83-
{
84-
#endif
85-
QPair< QString, QString> crses = mTransformContext.sourceDestinationDatumTransforms().keys().at( index.row() );
86-
sourceCrs = crses.first;
87-
destinationCrs = crses.second;
88-
const QgsDatumTransform::TransformPair transforms = mTransformContext.sourceDestinationDatumTransforms().value( crses );
89-
sourceTransform = transforms.sourceTransformId;
90-
destinationTransform = transforms.destinationTransformId;
91-
#ifdef singlesourcedest
92-
}
93-
#endif
76+
QPair< QString, QString> crses = mTransformContext.sourceDestinationDatumTransforms().keys().at( index.row() );
77+
sourceCrs = crses.first;
78+
destinationCrs = crses.second;
79+
const QgsDatumTransform::TransformPair transforms = mTransformContext.sourceDestinationDatumTransforms().value( crses );
80+
sourceTransform = transforms.sourceTransformId;
81+
destinationTransform = transforms.destinationTransformId;
9482

9583
switch ( role )
9684
{

‎src/core/qgscoordinatetransformcontext.cpp

Lines changed: 0 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -55,69 +55,9 @@ void QgsCoordinateTransformContext::clear()
5555
// play it safe
5656
d->mLock.lockForWrite();
5757
d->mSourceDestDatumTransforms.clear();
58-
#if 0
59-
d->mSourceDatumTransforms.clear();
60-
d->mDestDatumTransforms.clear();
61-
#endif
6258
d->mLock.unlock();
6359
}
6460

65-
#ifdef singlesourcedest
66-
QMap<QString, int> QgsCoordinateTransformContext::sourceDatumTransforms() const
67-
{
68-
d->mLock.lockForRead();
69-
auto res = d->mSourceDatumTransforms;
70-
res.detach();
71-
d->mLock.unlock();
72-
return res;
73-
}
74-
75-
bool QgsCoordinateTransformContext::addSourceDatumTransform( const QgsCoordinateReferenceSystem &crs, int transform )
76-
{
77-
if ( !crs.isValid() )
78-
return false;
79-
80-
d.detach();
81-
d->mLock.lockForWrite();
82-
d->mSourceDatumTransforms.insert( crs.authid(), transform );
83-
d->mLock.unlock();
84-
return true;
85-
}
86-
87-
void QgsCoordinateTransformContext::removeSourceDatumTransform( const QgsCoordinateReferenceSystem &crs )
88-
{
89-
d->mSourceDatumTransforms.remove( crs.authid() );
90-
}
91-
92-
QMap<QString, int> QgsCoordinateTransformContext::destinationDatumTransforms() const
93-
{
94-
d->mLock.lockForRead();
95-
auto res = d->mDestDatumTransforms;
96-
res.detach();
97-
d->mLock.unlock();
98-
return res;
99-
}
100-
101-
bool QgsCoordinateTransformContext::addDestinationDatumTransform( const QgsCoordinateReferenceSystem &crs, int transform )
102-
{
103-
if ( !crs.isValid() )
104-
return false;
105-
106-
d.detach();
107-
108-
d->mLock.lockForWrite();
109-
d->mDestDatumTransforms.insert( crs.authid(), transform );
110-
d->mLock.unlock();
111-
return true;
112-
}
113-
114-
void QgsCoordinateTransformContext::removeDestinationDatumTransform( const QgsCoordinateReferenceSystem &crs )
115-
{
116-
d->mDestDatumTransforms.remove( crs.authid() );
117-
}
118-
119-
#endif
120-
12161
QMap<QPair<QString, QString>, QgsDatumTransform::TransformPair> QgsCoordinateTransformContext::sourceDestinationDatumTransforms() const
12262
{
12363
d->mLock.lockForRead();
@@ -167,14 +107,6 @@ QgsDatumTransform::TransformPair QgsCoordinateTransformContext::calculateDatumTr
167107
}
168108
d->mLock.unlock();
169109
return res;
170-
171-
#ifdef singlesourcedest
172-
// fallback to checking src and dest separately
173-
int srcTransform = d->mSourceDatumTransforms.value( srcKey, -1 );
174-
int destTransform = d->mDestDatumTransforms.value( destKey, -1 );
175-
d->mLock.unlock();
176-
return qMakePair( srcTransform, destTransform );
177-
#endif
178110
}
179111

180112
bool QgsCoordinateTransformContext::readXml( const QDomElement &element, const QgsReadWriteContext &, QStringList &missingTransforms )
@@ -183,10 +115,6 @@ bool QgsCoordinateTransformContext::readXml( const QDomElement &element, const Q
183115
d->mLock.lockForWrite();
184116

185117
d->mSourceDestDatumTransforms.clear();
186-
#if 0
187-
d->mSourceDatumTransforms.clear();
188-
d->mDestDatumTransforms.clear();
189-
#endif
190118

191119
const QDomNodeList contextNodes = element.elementsByTagName( QStringLiteral( "transformContext" ) );
192120
if ( contextNodes.count() < 1 )
@@ -238,38 +166,6 @@ bool QgsCoordinateTransformContext::readXml( const QDomElement &element, const Q
238166
d->mSourceDestDatumTransforms.insert( qMakePair( key1, key2 ), QgsDatumTransform::TransformPair( datumId1, datumId2 ) );
239167
}
240168

241-
#if 0
242-
// src transforms
243-
const QDomNodeList srcNodes = contextElem.elementsByTagName( QStringLiteral( "source" ) );
244-
for ( int i = 0; i < srcNodes .size(); ++i )
245-
{
246-
const QDomElement transformElem = srcNodes.at( i ).toElement();
247-
QString key = transformElem.attribute( QStringLiteral( "crs" ) );
248-
QString value = transformElem.attribute( QStringLiteral( "transform" ) );
249-
if ( value.isEmpty() )
250-
continue;
251-
252-
int datumId = QgsCoordinateTransform::projStringToDatumTransformId( value );
253-
//TODO - throw warning if datumId is -1
254-
d->mSourceDatumTransforms.insert( key, datumId );
255-
}
256-
257-
// dest transforms
258-
const QDomNodeList destNodes = contextElem.elementsByTagName( QStringLiteral( "dest" ) );
259-
for ( int i = 0; i < destNodes.size(); ++i )
260-
{
261-
const QDomElement transformElem = destNodes.at( i ).toElement();
262-
QString key = transformElem.attribute( QStringLiteral( "crs" ) );
263-
QString value = transformElem.attribute( QStringLiteral( "transform" ) );
264-
if ( value.isEmpty() )
265-
continue;
266-
267-
int datumId = QgsCoordinateTransform::projStringToDatumTransformId( value );
268-
//TODO - throw warning if datumId is -1
269-
d->mDestDatumTransforms.insert( key, datumId );
270-
}
271-
#endif
272-
273169
d->mLock.unlock();
274170
return result;
275171
}
@@ -293,26 +189,6 @@ void QgsCoordinateTransformContext::writeXml( QDomElement &element, const QgsRea
293189
contextElem.appendChild( transformElem );
294190
}
295191

296-
#if 0
297-
// src transforms
298-
for ( auto it = d->mSourceDatumTransforms.constBegin(); it != d->mSourceDatumTransforms.constEnd(); ++ it )
299-
{
300-
QDomElement transformElem = element.ownerDocument().createElement( QStringLiteral( "source" ) );
301-
transformElem.setAttribute( QStringLiteral( "crs" ), it.key() );
302-
transformElem.setAttribute( QStringLiteral( "transform" ), it.value() < 0 ? QString() : it.value() );
303-
contextElem.appendChild( transformElem );
304-
}
305-
306-
// dest transforms
307-
for ( auto it = d->mDestDatumTransforms.constBegin(); it != d->mDestDatumTransforms.constEnd(); ++ it )
308-
{
309-
QDomElement transformElem = element.ownerDocument().createElement( QStringLiteral( "dest" ) );
310-
transformElem.setAttribute( QStringLiteral( "crs" ), it.key() );
311-
transformElem.setAttribute( QStringLiteral( "transform" ), it.value() < 0 ? QString() : it.value() );
312-
contextElem.appendChild( transformElem );
313-
}
314-
#endif
315-
316192
element.appendChild( contextElem );
317193
d->mLock.unlock();
318194
}
@@ -323,10 +199,6 @@ void QgsCoordinateTransformContext::readSettings()
323199
d->mLock.lockForWrite();
324200

325201
d->mSourceDestDatumTransforms.clear();
326-
#if 0
327-
d->mSourceDatumTransforms.clear();
328-
d->mDestDatumTransforms.clear();
329-
#endif
330202

331203
QgsSettings settings;
332204
settings.beginGroup( QStringLiteral( "/Projections" ) );

‎src/core/qgscoordinatetransformcontext.h

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,10 @@ class QDomElement;
4040
* \ingroup core
4141
* Contains information about the context in which a coordinate transform is executed.
4242
*
43-
* The context stores various information regarding which coordinate transforms should
43+
* The context stores various information regarding which coordinate operations should
4444
* be used when transforming points from a source to destination coordinate reference
4545
* system.
4646
*
47-
* The highest priority transforms are those set using addSourceDestinationDatumTransform()
48-
* and which the transform has a matching source to destination CRS pair.
49-
*
50-
* Failing this, if the source CRS has a matching transform specified by
51-
* addSourceDatumTransform() then this datum transform will be used. The same logic
52-
* applies for destination CRS transforms set using addDestinationDatumTransform().
53-
*
5447
* \note QgsCoordinateTransformContext objects are thread safe for read and write.
5548
*
5649
* \note QgsCoordinateTransformContext objects are implicitly shared.
@@ -89,94 +82,6 @@ class CORE_EXPORT QgsCoordinateTransformContext
8982
*/
9083
void clear();
9184

92-
93-
#if 0
94-
//singlesourcedest
95-
96-
/**
97-
* Returns the stored mapping for source CRS to associated datum transform to use.
98-
* The map keys will be QgsCoordinateReferenceSystems::authid()s.
99-
*
100-
* A datum transform of -1 indicates that no datum transform is required for the
101-
* source CRS.
102-
*
103-
* \warning This method should not be used to calculate the corresponding datum transforms
104-
* to use for a coordinate transform. Instead, always use calculateDatumTransforms()
105-
* to determine this.
106-
*
107-
* \see addSourceDatumTransform()
108-
* \see destinationDatumTransforms()
109-
*/
110-
QMap<QString, int> sourceDatumTransforms() const;
111-
112-
/**
113-
* Adds a new \a transform to use when projecting coordinates from the specified source
114-
* \a crs.
115-
*
116-
* A datum \a transform of -1 indicates that no datum transform is required for the
117-
* source CRS.
118-
*
119-
* Returns TRUE if the new transform was added successfully.
120-
*
121-
* \warning Transforms set using this method may be overridden by specific source/destination
122-
* transforms set by addSourceDestinationDatumTransform().
123-
*
124-
* \see sourceDatumTransforms()
125-
* \see addDestinationDatumTransform()
126-
* \see removeSourceDatumTransform()
127-
*/
128-
bool addSourceDatumTransform( const QgsCoordinateReferenceSystem &crs, int transform );
129-
130-
/**
131-
* Removes the source datum transform for the specified \a crs.
132-
* \see addSourceDatumTransform()
133-
* \see removeDestinationDatumTransform()
134-
*/
135-
void removeSourceDatumTransform( const QgsCoordinateReferenceSystem &crs );
136-
137-
/**
138-
* Returns the stored mapping for destination CRS to associated datum transform to use.
139-
* The map keys will be QgsCoordinateReferenceSystems::authid()s.
140-
*
141-
* A datum transform of -1 indicates that no datum transform is required for the
142-
* destination CRS.
143-
*
144-
* \warning This method should not be used to calculate the corresponding datum transforms
145-
* to use for a coordinate transform. Instead, always use calculateDatumTransforms()
146-
* to determine this.
147-
*
148-
* \see addDestinationDatumTransform()
149-
* \see sourceDatumTransforms()
150-
*/
151-
QMap< QString, int > destinationDatumTransforms() const;
152-
153-
/**
154-
* Adds a new \a transform to use when projecting coordinates to the specified destination
155-
* \a crs.
156-
*
157-
* A datum \a transform of -1 indicates that no datum transform is required for the
158-
* destination CRS.
159-
*
160-
* Returns TRUE if the new transform was added successfully.
161-
*
162-
* \warning Transforms set using this method may be overridden by specific source/destination
163-
* transforms set by addSourceDestinationDatumTransform().
164-
*
165-
* \see destinationDatumTransforms()
166-
* \see addSourceDatumTransform()
167-
* \see removeDestinationDatumTransform()
168-
*/
169-
bool addDestinationDatumTransform( const QgsCoordinateReferenceSystem &crs, int transform );
170-
171-
/**
172-
* Removes the destination datum transform for the specified \a crs.
173-
* \see addDestinationDatumTransform()
174-
* \see removeSourceDatumTransform()
175-
*/
176-
void removeDestinationDatumTransform( const QgsCoordinateReferenceSystem &crs );
177-
178-
#endif
179-
18085
/**
18186
* Returns the stored mapping for source to destination CRS pairs to associated datum transforms to use.
18287
* The map keys will be QgsCoordinateReferenceSystems::authid()s.

0 commit comments

Comments
 (0)
Please sign in to comment.