Skip to content
Permalink
Browse files

Fix #9070

  • Loading branch information
mhugent committed Nov 18, 2013
1 parent b21167c commit 51006cea1f2959b0e659a8ee07577632dc3c2753
Showing with 30 additions and 6 deletions.
  1. +28 −6 src/core/qgscoordinatetransform.cpp
  2. +2 −0 src/core/qgscoordinatetransform.h
@@ -193,14 +193,10 @@ void QgsCoordinateTransform::initialise()
{
destProjString += ( " " + datumTransformString( mDestinationDatumTransform ) );
}
else if ( !useDefaultDatumTransform && sourceProjString.contains( "+nadgrids" ) ) //add null grid if source transformation is ntv2
{
destProjString += " +nadgrids=@null";
}

if ( mSourceDatumTransform == -1 && !useDefaultDatumTransform && destProjString.contains( "+nadgrids" ) )
if ( !useDefaultDatumTransform )
{
sourceProjString += " +nadgrids=@null";
addNullGridShifts( sourceProjString, destProjString );
}

mDestinationProjection = pj_init_plus( destProjString.toUtf8() );
@@ -931,3 +927,29 @@ QString QgsCoordinateTransform::datumTransformString( int datumTransform )

return transformString;
}

void QgsCoordinateTransform::addNullGridShifts( QString& srcProjString, QString& destProjString )
{
//if one transformation uses ntv2, the other one needs to be null grid shift
if ( mDestinationDatumTransform == -1 && srcProjString.contains( "+nadgrids" ) ) //add null grid if source transformation is ntv2
{
destProjString += " +nadgrids=@null";
return;
}
if ( mSourceDatumTransform == -1 && destProjString.contains( "+nadgrids" ) )
{
srcProjString += " +nadgrids=@null";
return;
}

//add null shift grid for google mercator
//(see e.g. http://trac.osgeo.org/proj/wiki/FAQ#ChangingEllipsoidWhycantIconvertfromWGS84toGoogleEarthVirtualGlobeMercator)
if ( mSourceCRS.authid().compare( "EPSG:3857", Qt::CaseInsensitive ) == 0 && mSourceDatumTransform == -1 )
{
srcProjString += " +nadgrids=@null";
}
if ( mDestCRS.authid().compare( "EPSG:3857", Qt::CaseInsensitive ) == 0 && mDestinationDatumTransform == -1 )
{
destProjString += " +nadgrids=@null";
}
}
@@ -285,6 +285,8 @@ class CORE_EXPORT QgsCoordinateTransform : public QObject
/**Removes +nadgrids and +towgs84 from proj4 string*/
static QString stripDatumTransform( const QString& proj4 );
static void searchDatumTransform( const QString& sql, QList< int >& transforms );
/**In certain situations, null grid shifts have to be added to src / dst proj string*/
void addNullGridShifts( QString& srcProjString, QString& destProjString );
};

//! Output stream operator

0 comments on commit 51006ce

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