QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
qgscoordinatetransformcontext.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgscoordinatetransformcontext.cpp
3  ---------------------------------
4  begin : November 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
20 #include "qgscoordinatetransform.h"
21 #include "qgssettings.h"
22 #include "qgsprojutils.h"
23 
25 {
27 }
28 
29 template<>
30 bool qMapLessThanKey<QPair<QgsCoordinateReferenceSystem, QgsCoordinateReferenceSystem>>( const QPair<QgsCoordinateReferenceSystem, QgsCoordinateReferenceSystem> &key1,
31  const QPair<QgsCoordinateReferenceSystem, QgsCoordinateReferenceSystem> &key2 )
32 {
33  const QPair< QString, QString > key1String = qMakePair( crsToKey( key1.first ), crsToKey( key1.second ) );
34  const QPair< QString, QString > key2String = qMakePair( crsToKey( key2.first ), crsToKey( key2.second ) );
35  return key1String < key2String;
36 }
37 
39  : d( new QgsCoordinateTransformContextPrivate() )
40 {}
41 
43 
45  : d( rhs.d )
46 {}
47 
49 {
50  d = rhs.d;
51  return *this;
52 }
53 
55 {
56  if ( d == rhs.d )
57  return true;
58 
59  d->mLock.lockForRead();
60  rhs.d->mLock.lockForRead();
61  bool equal = d->mSourceDestDatumTransforms == rhs.d->mSourceDestDatumTransforms;
62  d->mLock.unlock();
63  rhs.d->mLock.unlock();
64  return equal;
65 }
66 
68 {
69  d.detach();
70  // play it safe
71  d->mLock.lockForWrite();
72  d->mSourceDestDatumTransforms.clear();
73  d->mLock.unlock();
74 }
75 
77 {
78 #if PROJ_VERSION_MAJOR>=6
79  return QMap<QPair<QString, QString>, QgsDatumTransform::TransformPair>();
80 #else
81  d->mLock.lockForRead();
82  auto res = d->mSourceDestDatumTransforms;
83  res.detach();
84  d->mLock.unlock();
85  return res;
86 #endif
87 }
88 
89 QMap<QPair<QString, QString>, QString> QgsCoordinateTransformContext::coordinateOperations() const
90 {
91 #if PROJ_VERSION_MAJOR>=6
92  d->mLock.lockForRead();
93  auto res = d->mSourceDestDatumTransforms;
94  res.detach();
95  d->mLock.unlock();
96  QMap<QPair<QString, QString>, QString> results;
97  for ( auto it = res.constBegin(); it != res.constEnd(); ++it )
98  results.insert( qMakePair( it.key().first.authid(), it.key().second.authid() ), it.value().operation );
99 
100  return results;
101 #else
102  return QMap<QPair<QString, QString>, QString>();
103 #endif
104 }
105 
106 bool QgsCoordinateTransformContext::addSourceDestinationDatumTransform( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, int sourceTransform, int destinationTransform )
107 {
108  if ( !sourceCrs.isValid() || !destinationCrs.isValid() )
109  return false;
110 #if PROJ_VERSION_MAJOR>=6
111  Q_UNUSED( sourceTransform )
112  Q_UNUSED( destinationTransform )
113  return false;
114 #else
115  d.detach();
116  d->mLock.lockForWrite();
117  d->mSourceDestDatumTransforms.insert( qMakePair( sourceCrs.authid(), destinationCrs.authid() ), QgsDatumTransform::TransformPair( sourceTransform, destinationTransform ) );
118  d->mLock.unlock();
119  return true;
120 #endif
121 }
122 
123 bool QgsCoordinateTransformContext::addCoordinateOperation( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QString &coordinateOperationProjString, bool allowFallback )
124 {
125  if ( !sourceCrs.isValid() || !destinationCrs.isValid() )
126  return false;
127 #if PROJ_VERSION_MAJOR>=6
128  d.detach();
129  d->mLock.lockForWrite();
130  QgsCoordinateTransformContextPrivate::OperationDetails details;
131  details.operation = coordinateOperationProjString;
132  details.allowFallback = allowFallback;
133  d->mSourceDestDatumTransforms.insert( qMakePair( sourceCrs, destinationCrs ), details );
134  d->mLock.unlock();
135  return true;
136 #else
137  Q_UNUSED( coordinateOperationProjString )
138  Q_UNUSED( allowFallback )
139  return false;
140 #endif
141 }
142 
144 {
145  removeCoordinateOperation( sourceCrs, destinationCrs );
146 }
147 
149 {
150 #if PROJ_VERSION_MAJOR>=6
151  d->mSourceDestDatumTransforms.remove( qMakePair( sourceCrs, destinationCrs ) );
152 #else
153  d->mSourceDestDatumTransforms.remove( qMakePair( sourceCrs.authid(), destinationCrs.authid() ) );
154 #endif
155 }
156 
158 {
159 #if PROJ_VERSION_MAJOR>=6
160  const QString t = calculateCoordinateOperation( source, destination );
161  return !t.isEmpty();
162 #else
166  // calculateDatumTransforms already takes care of switching source and destination
167  return t.sourceTransformId != -1 || t.destinationTransformId != -1;
168 #endif
169 }
170 
172 {
173 #if PROJ_VERSION_MAJOR>=6
174  Q_UNUSED( source )
175  Q_UNUSED( destination )
176  return QgsDatumTransform::TransformPair( -1, -1 );
177 #else
178  QString srcKey = source.authid();
179  QString destKey = destination.authid();
180 
181  d->mLock.lockForRead();
182  // highest priority is exact match for source/dest pair
183  QgsDatumTransform::TransformPair res = d->mSourceDestDatumTransforms.value( qMakePair( srcKey, destKey ), QgsDatumTransform::TransformPair( -1, -1 ) );
184  if ( res.sourceTransformId == -1 && res.destinationTransformId == -1 )
185  {
186  // try to reverse
187  QgsDatumTransform::TransformPair res2 = d->mSourceDestDatumTransforms.value( qMakePair( destKey, srcKey ), QgsDatumTransform::TransformPair( -1, -1 ) );
189  }
190  d->mLock.unlock();
191  return res;
192 #endif
193 }
194 
196 {
197 #if PROJ_VERSION_MAJOR>=6
198  if ( !source.isValid() || !destination.isValid() )
199  return QString();
200 
201  d->mLock.lockForRead();
202  QgsCoordinateTransformContextPrivate::OperationDetails res = d->mSourceDestDatumTransforms.value( qMakePair( source, destination ), QgsCoordinateTransformContextPrivate::OperationDetails() );
203  if ( res.operation.isEmpty() )
204  {
205  // try to reverse
206  res = d->mSourceDestDatumTransforms.value( qMakePair( destination, source ), QgsCoordinateTransformContextPrivate::OperationDetails() );
207  }
208  d->mLock.unlock();
209  return res.operation;
210 #else
211  Q_UNUSED( source )
212  Q_UNUSED( destination )
213  return QString();
214 #endif
215 }
216 
218 {
219 #if PROJ_VERSION_MAJOR>=6
220  if ( !source.isValid() || !destination.isValid() )
221  return false;
222 
223  d->mLock.lockForRead();
224  QgsCoordinateTransformContextPrivate::OperationDetails res = d->mSourceDestDatumTransforms.value( qMakePair( source, destination ), QgsCoordinateTransformContextPrivate::OperationDetails() );
225  if ( res.operation.isEmpty() )
226  {
227  // try to reverse
228  res = d->mSourceDestDatumTransforms.value( qMakePair( destination, source ), QgsCoordinateTransformContextPrivate::OperationDetails() );
229  }
230  d->mLock.unlock();
231  return res.allowFallback;
232 #else
233  Q_UNUSED( source )
234  Q_UNUSED( destination )
235  return false;
236 #endif
237 }
238 
240 {
241 #if PROJ_VERSION_MAJOR>=6
242  if ( !source.isValid() || !destination.isValid() )
243  return false;
244 
245  d->mLock.lockForRead();
246  QgsCoordinateTransformContextPrivate::OperationDetails res = d->mSourceDestDatumTransforms.value( qMakePair( source, destination ), QgsCoordinateTransformContextPrivate::OperationDetails() );
247  if ( !res.operation.isEmpty() )
248  {
249  d->mLock.unlock();
250  return false;
251  }
252  // see if the reverse operation is present
253  res = d->mSourceDestDatumTransforms.value( qMakePair( destination, source ), QgsCoordinateTransformContextPrivate::OperationDetails() );
254  if ( !res.operation.isEmpty() )
255  {
256  d->mLock.unlock();
257  return true;
258  }
259 
260  d->mLock.unlock();
261  return false;
262 #else
263  Q_UNUSED( source )
264  Q_UNUSED( destination )
265  return false;
266 #endif
267 }
268 
269 bool QgsCoordinateTransformContext::readXml( const QDomElement &element, const QgsReadWriteContext &, QStringList &missingTransforms )
270 {
271  d.detach();
272  d->mLock.lockForWrite();
273 
274  d->mSourceDestDatumTransforms.clear();
275 
276  const QDomNodeList contextNodes = element.elementsByTagName( QStringLiteral( "transformContext" ) );
277  if ( contextNodes.count() < 1 )
278  {
279  d->mLock.unlock();
280  return true;
281  }
282 
283  missingTransforms.clear();
284  bool result = true;
285 
286  const QDomElement contextElem = contextNodes.at( 0 ).toElement();
287 
288  // src/dest transforms
289  const QDomNodeList srcDestNodes = contextElem.elementsByTagName( QStringLiteral( "srcDest" ) );
290  for ( int i = 0; i < srcDestNodes.size(); ++i )
291  {
292  const QDomElement transformElem = srcDestNodes.at( i ).toElement();
293 
294 #if PROJ_VERSION_MAJOR>=6
295  const QDomElement srcElem = transformElem.firstChildElement( QStringLiteral( "src" ) );
296  const QDomElement destElem = transformElem.firstChildElement( QStringLiteral( "dest" ) );
297 
300  if ( !srcElem.isNull() && !destElem.isNull() )
301  {
302  srcCrs.readXml( srcElem );
303  destCrs.readXml( destElem );
304  }
305  else
306  {
307  // for older project compatibility
308  const QString key1 = transformElem.attribute( QStringLiteral( "source" ) );
309  const QString key2 = transformElem.attribute( QStringLiteral( "dest" ) );
310  srcCrs = QgsCoordinateReferenceSystem( key1 );
311  destCrs = QgsCoordinateReferenceSystem( key2 );
312  }
313 
314  if ( !srcCrs.isValid() || !destCrs.isValid() )
315  continue;
316 
317  const QString coordinateOp = transformElem.attribute( QStringLiteral( "coordinateOp" ) );
318  const bool allowFallback = transformElem.attribute( QStringLiteral( "allowFallback" ), QStringLiteral( "1" ) ).toInt();
319 
320  // try to instantiate operation, and check for missing grids
321  if ( !QgsProjUtils::coordinateOperationIsAvailable( coordinateOp ) )
322  {
323  // not possible in current Proj 6 api!
324  // QgsCoordinateTransform will alert users to this, we don't need to use missingTransforms here
325  result = false;
326  }
327 
328  QgsCoordinateTransformContextPrivate::OperationDetails deets;
329  deets.operation = coordinateOp;
330  deets.allowFallback = allowFallback;
331  d->mSourceDestDatumTransforms.insert( qMakePair( srcCrs, destCrs ), deets );
332 #else
333  const QString key1 = transformElem.attribute( QStringLiteral( "source" ) );
334  const QString key2 = transformElem.attribute( QStringLiteral( "dest" ) );
335 
336  QString value1 = transformElem.attribute( QStringLiteral( "sourceTransform" ) );
337  QString value2 = transformElem.attribute( QStringLiteral( "destTransform" ) );
338 
340  int datumId1 = -1;
341  int datumId2 = -1;
342  //warn if value1 or value2 is non-empty, yet no matching transform was found
343  if ( !value1.isEmpty() )
344  {
346  if ( datumId1 < 0 )
347  {
348  result = false;
349  missingTransforms << value1;
350  }
351  }
352  if ( !value2.isEmpty() )
353  {
355  if ( datumId2 < 0 )
356  {
357  result = false;
358  missingTransforms << value2;
359  }
360  }
362 
363  d->mSourceDestDatumTransforms.insert( qMakePair( key1, key2 ), QgsDatumTransform::TransformPair( datumId1, datumId2 ) );
364 #endif
365  }
366 
367  d->mLock.unlock();
368  return result;
369 }
370 
371 void QgsCoordinateTransformContext::writeXml( QDomElement &element, const QgsReadWriteContext & ) const
372 {
373  d->mLock.lockForRead();
374 
375  QDomDocument doc = element.ownerDocument();
376 
377  QDomElement contextElem = doc.createElement( QStringLiteral( "transformContext" ) );
378 
379  //src/dest transforms
380  for ( auto it = d->mSourceDestDatumTransforms.constBegin(); it != d->mSourceDestDatumTransforms.constEnd(); ++ it )
381  {
382  QDomElement transformElem = doc.createElement( QStringLiteral( "srcDest" ) );
383 #if PROJ_VERSION_MAJOR>=6
384  QDomElement srcElem = doc.createElement( QStringLiteral( "src" ) );
385  QDomElement destElem = doc.createElement( QStringLiteral( "dest" ) );
386 
387  it.key().first.writeXml( srcElem, doc );
388  it.key().second.writeXml( destElem, doc );
389 
390  transformElem.appendChild( srcElem );
391  transformElem.appendChild( destElem );
392 
393  transformElem.setAttribute( QStringLiteral( "coordinateOp" ), it.value().operation );
394  transformElem.setAttribute( QStringLiteral( "allowFallback" ), it.value().allowFallback ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
395 #else
396  transformElem.setAttribute( QStringLiteral( "source" ), it.key().first );
397  transformElem.setAttribute( QStringLiteral( "dest" ), it.key().second );
398 
400  transformElem.setAttribute( QStringLiteral( "sourceTransform" ), it.value().sourceTransformId < 0 ? QString() : QgsDatumTransform::datumTransformToProj( it.value().sourceTransformId ) );
401  transformElem.setAttribute( QStringLiteral( "destTransform" ), it.value().destinationTransformId < 0 ? QString() : QgsDatumTransform::datumTransformToProj( it.value().destinationTransformId ) );
403 #endif
404  contextElem.appendChild( transformElem );
405  }
406 
407  element.appendChild( contextElem );
408  d->mLock.unlock();
409 }
410 
412 {
413  d.detach();
414  d->mLock.lockForWrite();
415 
416  d->mSourceDestDatumTransforms.clear();
417 
418  QgsSettings settings;
419  settings.beginGroup( QStringLiteral( "/Projections" ) );
420  QStringList projectionKeys = settings.allKeys();
421 
422  //collect src and dest entries that belong together
423 #if PROJ_VERSION_MAJOR>=6
424  QMap< QPair< QgsCoordinateReferenceSystem, QgsCoordinateReferenceSystem >, QgsCoordinateTransformContextPrivate::OperationDetails > transforms;
425 #else
426  QMap< QPair< QString, QString >, QPair< int, int > > transforms;
427 #endif
428  QStringList::const_iterator pkeyIt = projectionKeys.constBegin();
429  for ( ; pkeyIt != projectionKeys.constEnd(); ++pkeyIt )
430  {
431 #if PROJ_VERSION_MAJOR>=6
432  if ( pkeyIt->contains( QLatin1String( "coordinateOp" ) ) )
433  {
434  QStringList split = pkeyIt->split( '/' );
435  QString srcAuthId, destAuthId;
436  if ( ! split.isEmpty() )
437  {
438  srcAuthId = split.at( 0 );
439  }
440  if ( split.size() > 1 )
441  {
442  destAuthId = split.at( 1 ).split( '_' ).at( 0 );
443  }
444 
445  if ( srcAuthId.isEmpty() || destAuthId.isEmpty() )
446  continue;
447 
448  const QString proj = settings.value( *pkeyIt ).toString();
449  const bool allowFallback = settings.value( QStringLiteral( "%1//%2_allowFallback" ).arg( srcAuthId, destAuthId ) ).toBool();
450  QgsCoordinateTransformContextPrivate::OperationDetails deets;
451  deets.operation = proj;
452  deets.allowFallback = allowFallback;
453  transforms[ qMakePair( QgsCoordinateReferenceSystem( srcAuthId ), QgsCoordinateReferenceSystem( destAuthId ) )] = deets;
454  }
455 #else
456  if ( pkeyIt->contains( QLatin1String( "srcTransform" ) ) || pkeyIt->contains( QLatin1String( "destTransform" ) ) )
457  {
458  QStringList split = pkeyIt->split( '/' );
459  QString srcAuthId, destAuthId;
460  if ( ! split.isEmpty() )
461  {
462  srcAuthId = split.at( 0 );
463  }
464  if ( split.size() > 1 )
465  {
466  destAuthId = split.at( 1 ).split( '_' ).at( 0 );
467  }
468 
469  QString proj = settings.value( *pkeyIt ).toString();
473  if ( pkeyIt->contains( QLatin1String( "srcTransform" ) ) )
474  {
475  transforms[ qMakePair( srcAuthId, destAuthId )].first = datumId;
476  }
477  else if ( pkeyIt->contains( QLatin1String( "destTransform" ) ) )
478  {
479  transforms[ qMakePair( srcAuthId, destAuthId )].second = datumId;
480  }
481  }
482 #endif
483  }
484 
485  // add transforms to context
486  auto transformIt = transforms.constBegin();
487  for ( ; transformIt != transforms.constEnd(); ++transformIt )
488  {
489 #if PROJ_VERSION_MAJOR>=6
490  d->mSourceDestDatumTransforms.insert( transformIt.key(), transformIt.value() );
491 #else
492  d->mSourceDestDatumTransforms.insert( transformIt.key(), QgsDatumTransform::TransformPair( transformIt.value().first, transformIt.value().second ) );
493 #endif
494  }
495 
496  d->mLock.unlock();
497  settings.endGroup();
498 }
499 
501 {
502  QgsSettings settings;
503  settings.beginGroup( QStringLiteral( "/Projections" ) );
504  QStringList groupKeys = settings.allKeys();
505  QStringList::const_iterator groupKeyIt = groupKeys.constBegin();
506  for ( ; groupKeyIt != groupKeys.constEnd(); ++groupKeyIt )
507  {
508  if ( groupKeyIt->contains( QLatin1String( "srcTransform" ) ) || groupKeyIt->contains( QLatin1String( "destTransform" ) ) || groupKeyIt->contains( QLatin1String( "coordinateOp" ) ) )
509  {
510  settings.remove( *groupKeyIt );
511  }
512  }
513 
514  for ( auto transformIt = d->mSourceDestDatumTransforms.constBegin(); transformIt != d->mSourceDestDatumTransforms.constEnd(); ++transformIt )
515  {
516 #if PROJ_VERSION_MAJOR>=6
517  const QString srcAuthId = transformIt.key().first.authid();
518  const QString destAuthId = transformIt.key().second.authid();
519 #else
520  const QString srcAuthId = transformIt.key().first;
521  const QString destAuthId = transformIt.key().second;
522 #endif
523 
524  if ( srcAuthId.isEmpty() || destAuthId.isEmpty() )
525  continue; // not so nice, but alternative would be to shove whole CRS wkt into the settings values...
526 
527 #if PROJ_VERSION_MAJOR>=6
528  const QString proj = transformIt.value().operation;
529  const bool allowFallback = transformIt.value().allowFallback;
530  settings.setValue( srcAuthId + "//" + destAuthId + "_coordinateOp", proj );
531  settings.setValue( srcAuthId + "//" + destAuthId + "_allowFallback", allowFallback );
532 #else
533  int sourceDatumTransform = transformIt.value().sourceTransformId;
534  QString sourceDatumProj;
536  if ( sourceDatumTransform >= 0 )
537  sourceDatumProj = QgsDatumTransform::datumTransformToProj( sourceDatumTransform );
538  int destinationDatumTransform = transformIt.value().destinationTransformId;
539  QString destinationDatumProj;
540  if ( destinationDatumTransform >= 0 )
541  destinationDatumProj = QgsDatumTransform::datumTransformToProj( destinationDatumTransform );
543 
544  settings.setValue( srcAuthId + "//" + destAuthId + "_srcTransform", sourceDatumProj );
545  settings.setValue( srcAuthId + "//" + destAuthId + "_destTransform", destinationDatumProj );
546 #endif
547  }
548 
549  settings.endGroup();
550 }
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
bool readXml(const QDomNode &node)
Restores state from the given DOM node.
QString authid() const
Returns the authority identifier for the CRS.
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
QString toWkt(WktVariant variant=WKT1_GDAL, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
Contains information about the context in which a coordinate transform is executed.
void clear()
Clears all stored transform information from the context.
bool allowFallbackTransform(const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination) const
Returns true if approximate "ballpark" transforms may be used when transforming between a source and ...
QString calculateCoordinateOperation(const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination) const
Returns the Proj coordinate operation string to use when transforming from the specified source CRS t...
void readSettings()
Reads the context's state from application settings.
void writeSettings()
Write the context's state to application settings.
Q_DECL_DEPRECATED bool addSourceDestinationDatumTransform(const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, int sourceTransformId, int destinationTransformId)
Adds a new sourceTransform and destinationTransform to use when projecting coordinates from the speci...
QMap< QPair< QString, QString >, QString > coordinateOperations() const
Returns the stored mapping for source to destination CRS pairs to associated coordinate operation to ...
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes the context's state to a DOM element.
Q_DECL_DEPRECATED QgsDatumTransform::TransformPair calculateDatumTransforms(const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination) const
Returns the pair of source and destination datum transforms to use for a transform from the specified...
Q_DECL_DEPRECATED QMap< QPair< QString, QString >, QgsDatumTransform::TransformPair > sourceDestinationDatumTransforms() const
Returns the stored mapping for source to destination CRS pairs to associated datum transforms to use.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context, QStringList &missingTransforms)
Reads the context's state from a DOM element.
bool addCoordinateOperation(const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QString &coordinateOperationProjString, bool allowFallback=true)
Adds a new coordinateOperationProjString to use when projecting coordinates from the specified source...
void removeCoordinateOperation(const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs)
Removes the coordinate operation for the specified sourceCrs and destinationCrs.
QgsCoordinateTransformContext()
Constructor for QgsCoordinateTransformContext.
bool hasTransform(const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination) const
Returns true if the context has a valid coordinate operation to use when transforming from the specif...
bool mustReverseCoordinateOperation(const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination) const
Returns true if the coordinate operation returned by calculateCoordinateOperation() for the source to...
bool operator==(const QgsCoordinateTransformContext &rhs) const
Q_DECL_DEPRECATED void removeSourceDestinationDatumTransform(const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs)
Removes the source to destination datum transform pair for the specified sourceCrs and destinationCrs...
QgsCoordinateTransformContext & operator=(const QgsCoordinateTransformContext &rhs)
Assignment operator.
static Q_DECL_DEPRECATED QString datumTransformToProj(int datumTransformId)
Returns a proj string representing the specified datumTransformId datum transform ID.
static Q_DECL_DEPRECATED int projStringToDatumTransformId(const QString &string)
Returns the datum transform ID corresponding to a specified proj string.
The class is used as a container of context for various read/write operations on other objects.
This class is a composition of two QSettings instances:
Definition: qgssettings.h:62
void endGroup()
Resets the group to what it was before the corresponding beginGroup() call.
Definition: qgssettings.cpp:97
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void beginGroup(const QString &prefix, QgsSettings::Section section=QgsSettings::NoSection)
Appends prefix to the current group.
Definition: qgssettings.cpp:87
void remove(const QString &key, QgsSettings::Section section=QgsSettings::NoSection)
Removes the setting key and any sub-settings of key in a section.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
QStringList allKeys() const
Returns a list of all keys, including subkeys, that can be read using the QSettings object.
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:798
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:797
QString crsToKey(const QgsCoordinateReferenceSystem &crs)
const QgsCoordinateReferenceSystem & crs
Contains datum transform information.
int sourceTransformId
ID for the datum transform to use when projecting from the source CRS.
int destinationTransformId
ID for the datum transform to use when projecting to the destination CRS.