Skip to content

Commit b8a2f0c

Browse files
committed
Update also crs transform cache if a crs has been updated
1 parent 1962c3c commit b8a2f0c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/core/qgscrscache.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,28 @@ const QgsCoordinateTransform* QgsCoordinateTransformCache::transform( const QStr
5757
}
5858
}
5959

60+
void QgsCoordinateTransformCache::invalidateCrs( const QString& crsAuthId )
61+
{
62+
//get keys to remove first
63+
QHash< QPair< QString, QString >, QgsCoordinateTransform* >::iterator it = mTransforms.begin();
64+
QList< QPair< QString, QString > > updateList;
65+
66+
for ( ; it != mTransforms.end(); ++it )
67+
{
68+
if ( it.key().first == crsAuthId || it.key().second == crsAuthId )
69+
{
70+
updateList.append( it.key() );
71+
}
72+
}
73+
74+
//and remove after
75+
QList< QPair< QString, QString > >::const_iterator updateIt = updateList.constBegin();
76+
for ( ; updateIt != updateList.constEnd(); ++updateIt )
77+
{
78+
mTransforms.remove( *updateIt );
79+
}
80+
}
81+
6082
QgsCRSCache* QgsCRSCache::mInstance = 0;
6183

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

89112
const QgsCoordinateReferenceSystem& QgsCRSCache::crsByAuthId( const QString& authid )

src/core/qgscrscache.h

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class CORE_EXPORT QgsCoordinateTransformCache
3434
@param srcAuthId auth id string of source crs
3535
@param destAuthId auth id string of dest crs*/
3636
const QgsCoordinateTransform* transform( const QString& srcAuthId, const QString& destAuthId );
37+
/**Removes transformations where a changed crs is involved from the cache*/
38+
void invalidateCrs( const QString& crsAuthId );
3739

3840
private:
3941
static QgsCoordinateTransformCache* mInstance;

0 commit comments

Comments
 (0)