Skip to content
Permalink
Browse files

Datum transform dialog: show tooltip with transform code and src/dest…

… CRS description
  • Loading branch information
mhugent committed Nov 25, 2013
1 parent fc115a4 commit 0ca0d50b51659c70bf70398127fb162582efad8b
Showing with 47 additions and 0 deletions.
  1. +37 −0 src/core/qgscoordinatetransform.cpp
  2. +2 −0 src/core/qgscoordinatetransform.h
  3. +8 −0 src/gui/qgsdatumtransformdialog.cpp
@@ -932,6 +932,43 @@ QString QgsCoordinateTransform::datumTransformString( int datumTransform )
return transformString;
}

bool QgsCoordinateTransform::datumTransformCrsInfo( int datumTransform, QString& srcProjection, QString& dstProjection )
{
sqlite3* db;
int openResult = sqlite3_open( QgsApplication::srsDbFilePath().toUtf8().constData(), &db );
if ( openResult != SQLITE_OK )
{
sqlite3_close( db );
return false;
}

sqlite3_stmt* stmt;
QString sql = QString( "SELECT source_crs_code, target_crs_code FROM tbl_datum_transform WHERE coord_op_code = %1" ).arg( datumTransform );
int prepareRes = sqlite3_prepare( db, sql.toAscii(), sql.size(), &stmt, NULL );
if ( prepareRes != SQLITE_OK )
{
sqlite3_finalize( stmt ); sqlite3_close( db );
return false;
}

int srcCrsId, destCrsId;
if ( sqlite3_step( stmt ) == SQLITE_ROW )
{
srcCrsId = sqlite3_column_int( stmt, 0 );
destCrsId = sqlite3_column_int( stmt, 1 );
}

QgsCoordinateReferenceSystem srcCrs;
srcCrs.createFromOgcWmsCrs( QString( "EPSG:%1" ).arg( srcCrsId ) );
srcProjection = srcCrs.description();
QgsCoordinateReferenceSystem destCrs;
destCrs.createFromOgcWmsCrs( QString( "EPSG:%1" ).arg( destCrsId ) );
dstProjection = destCrs.description();

sqlite3_finalize( stmt ); sqlite3_close( db );
return true;
}

void QgsCoordinateTransform::addNullGridShifts( QString& srcProjString, QString& destProjString )
{
//if one transformation uses ntv2, the other one needs to be null grid shift
@@ -214,6 +214,8 @@ class CORE_EXPORT QgsCoordinateTransform : public QObject
/**Returns list of datum transformations for the given src and dest CRS*/
static QList< QList< int > > datumTransformations( const QgsCoordinateReferenceSystem& srcCRS, const QgsCoordinateReferenceSystem& destCRS );
static QString datumTransformString( int datumTransform );
/**Gets name of source and dest geographical CRS (to show in a tooltip)*/
static bool datumTransformCrsInfo( int datumTransform, QString& srcProjection, QString& dstProjection );

int sourceDatumTransform() const { return mSourceDatumTransform; }
void setSourceDatumTransform( int dt ) { mSourceDatumTransform = dt; }
@@ -41,6 +41,14 @@ QgsDatumTransformDialog::QgsDatumTransformDialog( const QString& layerName, cons
if ( nr != -1 )
{
item->setText( i, QgsCoordinateTransform::datumTransformString( nr ) );

//Describe datums in a tooltip
QString srcGeoProj, destGeoProj;
if ( QgsCoordinateTransform::datumTransformCrsInfo( nr, srcGeoProj, destGeoProj ) )
{
QString toolTipString = QString( "EPSG Transformations Code: %1\nSource CRS: %2\nDestination CRS: %3" ).arg( nr ).arg( srcGeoProj ).arg( destGeoProj );
item->setToolTip( i, toolTipString );
}
}

if ( gridShiftTransformation( item->text( i ) ) && !testGridShiftFileAvailability( item, i ) )

0 comments on commit 0ca0d50

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