Navigation Menu

Skip to content

Commit

Permalink
fix #2315
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12640 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Dec 28, 2009
1 parent c122111 commit a13c99d
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/core/qgscoordinatetransform.cpp
Expand Up @@ -22,7 +22,6 @@
//qt includes
#include <QDomNode>
#include <QDomElement>
#include <QTextStream>
#include <QApplication>
#include "qgslogger.h"

Expand Down Expand Up @@ -227,7 +226,7 @@ QgsPoint QgsCoordinateTransform::transform( const QgsPoint thePoint, TransformDi
catch ( QgsCsException &cse )
{
// rethrow the exception
QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
QgsDebugMsg( "rethrowing exception" );
throw cse;
}

Expand All @@ -244,7 +243,7 @@ QgsPoint QgsCoordinateTransform::transform( const double theX, const double theY
catch ( QgsCsException &cse )
{
// rethrow the exception
QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
QgsDebugMsg( "rethrowing exception" );
throw cse;
}
}
Expand All @@ -270,7 +269,7 @@ QgsRectangle QgsCoordinateTransform::transform( const QgsRectangle theRect, Tran
catch ( QgsCsException &cse )
{
// rethrow the exception
QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
QgsDebugMsg( "rethrowing exception" );
throw cse;
}

Expand Down Expand Up @@ -304,7 +303,7 @@ void QgsCoordinateTransform::transformInPlace( double& x, double& y, double& z,
catch ( QgsCsException &cse )
{
// rethrow the exception
QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
QgsDebugMsg( "rethrowing exception" );
throw cse;
}
}
Expand All @@ -330,7 +329,7 @@ void QgsCoordinateTransform::transformInPlace( std::vector<double>& x,
catch ( QgsCsException &cse )
{
// rethrow the exception
QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
QgsDebugMsg( "rethrowing exception" );
throw cse;
}
}
Expand Down Expand Up @@ -394,7 +393,7 @@ QgsRectangle QgsCoordinateTransform::transformBoundingBox( const QgsRectangle re
catch ( QgsCsException &cse )
{
// rethrow the exception
QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
QgsDebugMsg( "rethrowing exception" );
throw cse;
}

Expand Down Expand Up @@ -454,42 +453,44 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
if ( direction == ReverseTransform )
{
projResult = pj_transform( mDestinationProjection, mSourceProjection, numPoints, 0, x, y, z );
dir = "inverse";
dir = tr( "inverse" );
}
else
{
assert( mSourceProjection != 0 );
assert( mDestinationProjection != 0 );
projResult = pj_transform( mSourceProjection, mDestinationProjection, numPoints, 0, x, y, z );
dir = "forward";
dir = tr( "forward" );
}

if ( projResult != 0 )
{
//something bad happened....
QString msg;
QTextStream pjErr( &msg );
QString points;

pjErr << tr( "Failed" ) << " " << dir << " " << tr( "transform of" ) << '\n';
for ( int i = 0; i < numPoints; ++i )
{
if ( direction == ForwardTransform )
{
pjErr << "(" << x[i] << ", " << y[i] << ")\n";
points += QString("(%1, %2)\n").arg( x[i] ).arg( y[i] );
}
else
{
pjErr << "(" << x[i] * RAD_TO_DEG << ", " << y[i] * RAD_TO_DEG << ")\n";
points += QString("(%1, %2)\n").arg( x[i]*RAD_TO_DEG ).arg( y[i]*RAD_TO_DEG );
}
}

pjErr << tr( "with error: " ) << QString::fromUtf8( pj_strerrno( projResult ) ) << '\n';
QString msg = tr("%1 transform of\n%2\nfailed with error: %3\n")
.arg( dir )
.arg( points )
.arg( QString::fromUtf8( pj_strerrno( projResult ) ) ) );

QgsDebugMsg( "Projection failed emitting invalid transform signal: " + QString( msg.toLocal8Bit().data() ) );
QgsDebugMsg( "Projection failed emitting invalid transform signal: " + msg );

emit invalidTransformInput();

QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
QgsDebugMsg( "throwing exception" );

throw QgsCsException( msg );
}

Expand Down

0 comments on commit a13c99d

Please sign in to comment.