Skip to content
Permalink
Browse files

Update also crs transform cache if a crs has been updated

  • Loading branch information
mhugent committed Jun 14, 2013
1 parent 1962c3c commit b8a2f0c1aa9d49dadfa2e5174b00a2a55ac13cea
Showing with 25 additions and 0 deletions.
  1. +23 −0 src/core/qgscrscache.cpp
  2. +2 −0 src/core/qgscrscache.h
@@ -57,6 +57,28 @@ const QgsCoordinateTransform* QgsCoordinateTransformCache::transform( const QStr
}
}

void QgsCoordinateTransformCache::invalidateCrs( const QString& crsAuthId )
{
//get keys to remove first
QHash< QPair< QString, QString >, QgsCoordinateTransform* >::iterator it = mTransforms.begin();
QList< QPair< QString, QString > > updateList;

for ( ; it != mTransforms.end(); ++it )
{
if ( it.key().first == crsAuthId || it.key().second == crsAuthId )
{
updateList.append( it.key() );
}
}

//and remove after
QList< QPair< QString, QString > >::const_iterator updateIt = updateList.constBegin();
for ( ; updateIt != updateList.constEnd(); ++updateIt )
{
mTransforms.remove( *updateIt );
}
}

QgsCRSCache* QgsCRSCache::mInstance = 0;

QgsCRSCache* QgsCRSCache::instance()
@@ -84,6 +106,7 @@ void QgsCRSCache::updateCRSCache( const QString& authid )
{
mCRS.insert( authid, s );
}
QgsCoordinateTransformCache::instance()->invalidateCrs( authid );
}

const QgsCoordinateReferenceSystem& QgsCRSCache::crsByAuthId( const QString& authid )
@@ -34,6 +34,8 @@ class CORE_EXPORT QgsCoordinateTransformCache
@param srcAuthId auth id string of source crs
@param destAuthId auth id string of dest crs*/
const QgsCoordinateTransform* transform( const QString& srcAuthId, const QString& destAuthId );
/**Removes transformations where a changed crs is involved from the cache*/
void invalidateCrs( const QString& crsAuthId );

private:
static QgsCoordinateTransformCache* mInstance;

0 comments on commit b8a2f0c

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