Skip to content
Permalink
Browse files

Improve caching of transforms

  • Loading branch information
nyalldawson committed Nov 6, 2017
1 parent 0a9c107 commit 1422d5382c55c0c35c93029c78e4f5d8b11700c1
Showing with 29 additions and 0 deletions.
  1. +25 −0 src/core/qgscoordinatetransform.cpp
  2. +4 −0 src/gui/qgsdatumtransformdialog.h
@@ -52,6 +52,10 @@ QgsCoordinateTransform::QgsCoordinateTransform()
QgsCoordinateTransform::QgsCoordinateTransform( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination )
{
d = new QgsCoordinateTransformPrivate( source, destination, QgsCoordinateTransformContext() );

if ( !d->mSourceCRS.isValid() || !d->mDestCRS.isValid() )
return;

if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) )
{
d->initialize();
@@ -65,6 +69,10 @@ QgsCoordinateTransform::QgsCoordinateTransform( const QgsCoordinateReferenceSyst
#ifdef QGISDEBUG
d->mHasContext = true;
#endif

if ( !d->mSourceCRS.isValid() || !d->mDestCRS.isValid() )
return;

if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) )
{
d->initialize();
@@ -78,6 +86,10 @@ QgsCoordinateTransform::QgsCoordinateTransform( const QgsCoordinateReferenceSyst
#ifdef QGISDEBUG
d->mHasContext = true;
#endif

if ( !d->mSourceCRS.isValid() || !d->mDestCRS.isValid() )
return;

if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) )
{
d->initialize();
@@ -91,6 +103,10 @@ QgsCoordinateTransform::QgsCoordinateTransform( const QgsCoordinateReferenceSyst
#ifdef QGISDEBUG
d->mHasContext = true; // not strictly true, but we don't need to worry if datums have been explicitly set
#endif

if ( !d->mSourceCRS.isValid() || !d->mDestCRS.isValid() )
return;

if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) )
{
d->initialize();
@@ -115,6 +131,9 @@ void QgsCoordinateTransform::setSourceCrs( const QgsCoordinateReferenceSystem &c
{
d.detach();
d->mSourceCRS = crs;
if ( !d->mSourceCRS.isValid() || !d->mDestCRS.isValid() )
return;

d->calculateTransforms();
if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) )
{
@@ -126,6 +145,9 @@ void QgsCoordinateTransform::setDestinationCrs( const QgsCoordinateReferenceSyst
{
d.detach();
d->mDestCRS = crs;
if ( !d->mSourceCRS.isValid() || !d->mDestCRS.isValid() )
return;

d->calculateTransforms();
if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) )
{
@@ -141,6 +163,9 @@ void QgsCoordinateTransform::setContext( const QgsCoordinateTransformContext &co
#ifdef QGISDEBUG
d->mHasContext = true;
#endif
if ( !d->mSourceCRS.isValid() || !d->mDestCRS.isValid() )
return;

d->calculateTransforms();
if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mSourceDatumTransform, d->mDestinationDatumTransform ) )
{
@@ -33,6 +33,10 @@ class GUI_EXPORT QgsDatumTransformDialog : public QDialog, private Ui::QgsDatumT
{
Q_OBJECT
public:

/**
* Constructor for QgsDatumTransformDialog.
*/
QgsDatumTransformDialog( const QList< QList< int > > &dt, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr );
~QgsDatumTransformDialog();

0 comments on commit 1422d53

Please sign in to comment.
You can’t perform that action at this time.