Skip to content
Permalink
Browse files

Fix proj string manipulation for reverse datum transformations

  • Loading branch information
mhugent committed Nov 18, 2013
1 parent 99cee10 commit b21167c5b6e0006fc3a934560b819dbcf510189a
Showing with 16 additions and 6 deletions.
  1. +15 −2 src/core/qgscoordinatetransform.cpp
  2. +1 −4 src/gui/qgsdatumtransformdialog.cpp
@@ -193,10 +193,16 @@ void QgsCoordinateTransform::initialise()
{
destProjString += ( " " + datumTransformString( mDestinationDatumTransform ) );
}
else if ( sourceProjString.contains( "+nadgrids" ) ) //add null grid if source transformation is ntv2
else if ( !useDefaultDatumTransform && sourceProjString.contains( "+nadgrids" ) ) //add null grid if source transformation is ntv2
{
destProjString += " +nadgrids=@null";
}

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

mDestinationProjection = pj_init_plus( destProjString.toUtf8() );

#ifdef COORDINATE_TRANSFORM_VERBOSE
@@ -792,8 +798,9 @@ QList< QList< int > > QgsCoordinateTransform::datumTransformations( const QgsCoo
QList<int> directTransforms;
searchDatumTransform( QString( "SELECT coord_op_code FROM tbl_datum_transform WHERE source_crs_code = %1 AND target_crs_code = %2" ).arg( srcAuthCode ).arg( destAuthCode ),
directTransforms );
QList<int> reverseDirectTransforms;
searchDatumTransform( QString( "SELECT coord_op_code FROM tbl_datum_transform WHERE source_crs_code = %1 AND target_crs_code = %2" ).arg( destAuthCode ).arg( srcAuthCode ),
directTransforms );
reverseDirectTransforms );
QList<int> srcToWgs84;
searchDatumTransform( QString( "SELECT coord_op_code FROM tbl_datum_transform WHERE ( source_crs_code = %1 AND target_crs_code = %2 ) OR ( source_crs_code = %2 AND target_crs_code = %1 )" ).arg( srcAuthCode ).arg( 4326 ),
srcToWgs84 );
@@ -808,6 +815,12 @@ QList< QList< int > > QgsCoordinateTransform::datumTransformations( const QgsCoo
transformations.push_back( QList<int>() << *directIt << -1 );
}

//add direct datum transformations
directIt = reverseDirectTransforms.constBegin();
for ( ; directIt != reverseDirectTransforms.constEnd(); ++directIt )
{
transformations.push_back( QList<int>() << -1 << *directIt );
}

QList<int>::const_iterator srcWgsIt = srcToWgs84.constBegin();
for ( ; srcWgsIt != srcToWgs84.constEnd(); ++srcWgsIt )
@@ -71,10 +71,7 @@ QList< int > QgsDatumTransformDialog::selectedDatumTransform()
for ( int i = 0; i < 2; ++i )
{
int transformNr = item->data( i, Qt::UserRole ).toInt();
if ( transformNr != -1 )
{
list << transformNr;
}
list << transformNr;
}
}
return list;

0 comments on commit b21167c

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