@@ -193,14 +193,10 @@ void QgsCoordinateTransform::initialise()
193
193
{
194
194
destProjString += ( " " + datumTransformString ( mDestinationDatumTransform ) );
195
195
}
196
- else if ( !useDefaultDatumTransform && sourceProjString.contains ( " +nadgrids" ) ) // add null grid if source transformation is ntv2
197
- {
198
- destProjString += " +nadgrids=@null" ;
199
- }
200
196
201
- if ( mSourceDatumTransform == - 1 && !useDefaultDatumTransform && destProjString. contains ( " +nadgrids " ) )
197
+ if ( !useDefaultDatumTransform )
202
198
{
203
- sourceProjString += " +nadgrids=@null " ;
199
+ addNullGridShifts ( sourceProjString, destProjString ) ;
204
200
}
205
201
206
202
mDestinationProjection = pj_init_plus ( destProjString.toUtf8 () );
@@ -931,3 +927,29 @@ QString QgsCoordinateTransform::datumTransformString( int datumTransform )
931
927
932
928
return transformString;
933
929
}
930
+
931
+ void QgsCoordinateTransform::addNullGridShifts ( QString& srcProjString, QString& destProjString )
932
+ {
933
+ // if one transformation uses ntv2, the other one needs to be null grid shift
934
+ if ( mDestinationDatumTransform == -1 && srcProjString.contains ( " +nadgrids" ) ) // add null grid if source transformation is ntv2
935
+ {
936
+ destProjString += " +nadgrids=@null" ;
937
+ return ;
938
+ }
939
+ if ( mSourceDatumTransform == -1 && destProjString.contains ( " +nadgrids" ) )
940
+ {
941
+ srcProjString += " +nadgrids=@null" ;
942
+ return ;
943
+ }
944
+
945
+ // add null shift grid for google mercator
946
+ // (see e.g. http://trac.osgeo.org/proj/wiki/FAQ#ChangingEllipsoidWhycantIconvertfromWGS84toGoogleEarthVirtualGlobeMercator)
947
+ if ( mSourceCRS .authid ().compare ( " EPSG:3857" , Qt::CaseInsensitive ) == 0 && mSourceDatumTransform == -1 )
948
+ {
949
+ srcProjString += " +nadgrids=@null" ;
950
+ }
951
+ if ( mDestCRS .authid ().compare ( " EPSG:3857" , Qt::CaseInsensitive ) == 0 && mDestinationDatumTransform == -1 )
952
+ {
953
+ destProjString += " +nadgrids=@null" ;
954
+ }
955
+ }
0 commit comments